package org.playground.booking.security.dao.Impl;

import org.hibernate.query.Query;
import org.playground.booking.auth.entity.Customer;
import org.playground.booking.security.dao.ICustomerDao;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class CustomerDao extends AbstractDao<Customer,Integer> implements ICustomerDao {


    @Override
    public Customer loadCustomerByName(String userName) {
        String hql = "from Customer where name=:name";
        Query query = this.getCurrentSession().createQuery(hql);
        query.setParameter("name",userName);
        List<Customer> customerList = query.list();
        return customerList.size()==0?null:customerList.get(0);
    }
}
